/**
 * <p>Copyright (c) 2017 深圳市鹏途交通科技有限公司 </p>
 * <p>				   All right reserved. 		     </p>
 * 
 * <p>项目名称 ： 	深圳市国省检日常化监管系统         </p>
 * <p>创建者   :	heyong 
 * 
 * <p>描   述  :   PrevenManagementController.java for com.pengtu.gsj.controller.jsbz    </p>
 * 
 * <p>最后修改 : $: 2017年8月10日-上午9:16:24 v 1.0.0	 heyong   $ </p>
 * 
*/

package com.pengtu.gsj.controller.jsbz;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.pengtu.gsj.controller.base.DefaultBaseController;
import com.pengtu.gsj.dao.base.Page;
import com.pengtu.gsj.dao.base.QueryFilter;
import com.pengtu.gsj.entity.jsbz.PrevenManagement;
import com.pengtu.gsj.interceptor.Token;
import com.pengtu.gsj.service.jsbz.PrevenManagementService;
import com.pengtu.gsj.utils.web.SpringMvcUtils;

/**
 * 
 * PrevenManagementController
 * 
 * 2017年8月10日 上午9:16:24
 * 
 * @version 1.0.0
 * 
 */
@Controller
@RequestMapping("prevenManagement")
public class PrevenManagementController extends DefaultBaseController {
	
	@Autowired
	private PrevenManagementService prevenManagementService;
	
	
	
	/**
	 * 加载
	 * @param id
	 * @return
	 */
	@ModelAttribute
	public PrevenManagement load(String id){
		PrevenManagement prevenManagement;
		if(StringUtils.isNotEmpty(id)){
			prevenManagement = prevenManagementService.getPrevenManagementById(id);
		}else{
			prevenManagement = new PrevenManagement();
		}
		return prevenManagement;
	}
	
	
	/**
	 * 页面跳转
	 * @return
	 */
	@RequestMapping("listInfo")
	@Token(save = true)
	public String showLisfInfo() {
		return "jsbz/prevenManagement_list";
	}
	
	
	@RequestMapping(value="list", produces = "application/json; charset=utf-8")
	@ResponseBody
	public Page<PrevenManagement> getRoadMaterialList(Page<PrevenManagement> page, HttpServletRequest request){
		QueryFilter queryFilter = QueryFilter.buildFromHttpRequest(request);
		if (!page.isOrderBySetted()) {
			page.setOrderBy("testYear");
			page.setOrder(Page.ASC);
		}
		page = prevenManagementService.findPrevenManagement(page,queryFilter);
		return page;
	}
	
	/**
	 * 保存
	 * @param roadMaterial
	 * @return
	 */
	@RequestMapping(value = "save", method=RequestMethod.POST)
	@ResponseBody
	@Token(remove = true)
	public boolean savePrevenManagement(@ModelAttribute PrevenManagement prevenManagement){
		prevenManagementService.savePrevenManagement(prevenManagement);
		return true;
	}
	
	
	/**
	 * 加载数据
	 * @param infoManagement
	 * @return
	 */
	@RequestMapping(value="show")
	@ResponseBody                                                     
	public PrevenManagement showPrevenManagement (@ModelAttribute PrevenManagement prevenManagement){
		return prevenManagement;
	}
	
	/**
	 * 删除
	 * @param infoManagement
	 * @return
	 */
	@RequestMapping(value="delete")
	@ResponseBody
	public boolean delateInfoManagement(@ModelAttribute PrevenManagement prevenManagement){
		prevenManagementService.delatePrevenManagement(prevenManagement);
		return true;
	}
	
	@ResponseBody
	@RequestMapping(value="checkTecYear")
	public boolean checkTecYear(){
		String testYear = SpringMvcUtils.getParameter("testYear");
		String id = SpringMvcUtils.getParameter("id");
		return prevenManagementService.checkTecYear(testYear, id);
	}
}
